package com.wangzhixuan.commons.result;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * 树结构
 *
 * @author lixin
 */
@Data
@ApiModel("easyui树结构数据")
public class Tree implements Serializable {
    @ApiModelProperty("编号")
    private Long id;
    @ApiModelProperty("标题")
    private String text;
    @ApiModelProperty("open、close")
    private String state = "open";
    @ApiModelProperty("是否选中")
    private boolean checked = false;
    @ApiModelProperty("其它属性")
    private Object attributes;
    @ApiModelProperty("子树")
    private List<Tree> children;
    @ApiModelProperty("图标")
    private String iconCls;
    @ApiModelProperty("父级树编号")
    private Long pid;
    @ApiModelProperty("打开方式 ajax、iframe")
    private String openMode;
    public void setState(Integer opened) {
        this.state = (null != opened && opened == 1) ? "open" : "closed";
    }

}
